// This is the main DLL file.

#include "stdafx.h"
#include <mscoree.h>
#include <eh.h>

#include "Common.h"
#include "Patch.h"
#include "WMP.h"

#pragma unmanaged

HMODULE HInstance;
HMODULE HINST;

void Init(HMODULE hInst, ULONG ul_reason_for_call) {
	if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
		HInstance = hInst;
	}
}

BOOL WINAPI DllMain(HMODULE hInst, ULONG ul_reason_for_call,LPVOID lpReserved) {
	CreatePathBuffer(pathBuffer);

	Init(hInst, ul_reason_for_call);
	if (ul_reason_for_call == DLL_PROCESS_ATTACH)
		DisableThreadLibraryCalls(hInst);
	if (ul_reason_for_call != DLL_PROCESS_DETACH) {
		GetModuleFileName(NULL, pathBuffer, pathBufferLength);
		Patch(GetModuleHandle(NULL), pathBuffer, PATCH_ACTION_WMPLAYER);
	}

	return TRUE;
}
